import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { HostVO, HostForm, HostQuery } from '@/api/tool/host/types';

/**
 * 查询主机列表
 * @param query
 * @returns {*}
 */

export const listHost = (query?: HostQuery): AxiosPromise<HostVO[]> => {
  return request({
    url: '/tool/asset/host/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询主机详细
 * @param id
 */
export const getHost = (id: string | number): AxiosPromise<HostVO> => {
  return request({
    url: '/tool/asset/host/' + id,
    method: 'get'
  });
};

/**
 * 新增主机
 * @param data
 */
export const addHost = (data: HostForm) => {
  return request({
    url: '/tool/asset/host',
    method: 'post',
    data: data
  });
};

/**
 * 修改主机
 * @param data
 */
export const updateHost = (data: HostForm) => {
  return request({
    url: '/tool/asset/host',
    method: 'put',
    data: data
  });
};

/**
 * 删除主机
 * @param id
 */
export const delHost = (id: string | number | Array<string | number>) => {
  return request({
    url: '/tool/asset/host/' + id,
    method: 'delete'
  });
};
